<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>XMP Toolkit SDK: Main Page</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xmp_tagline_small.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">XMP Toolkit SDK
   &#160;<span id="projectnumber">6.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">XMP Toolkit SDK Documentation</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The XMPCore component provides the tools that allow you to parse, manipulate, and serialize XMP data, according to the Data Model and Serialization Model given in the XMP Specification. XMPCore has no knowledge of files. <br />
<br />
 The client view of the XMPCore API is provided through these C++ class templates:</p>
<ul>
<li><code><a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a></code> provides the fundamental methods for manipulating XMP metadata. </li>
<li><code><a class="el" href="classTXMPIterator.html" title="API for access to the XMP Toolkit iteration services. ">TXMPIterator</a></code> provides methods to iterate over existing XMP metadata. </li>
<li><code><a class="el" href="classTXMPUtils.html" title="API for access to the XMP Toolkit utility services. ">TXMPUtils</a></code> provides additional utilities layered on top of <code><a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a></code>.</li>
</ul>
<p>The XMPFiles component provides support for locating the XMP in a file, adding XMP to a file, or updating the XMP in a file. Use it to retrieve an entire XMP packet from a file, which you can either manipulate directly or use to create a <code><a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a></code> object, so that you can use the XMPCore component to manipulate the individual XMP properties. XMPFiles contains a number of format-specific file handlers that know how to efficiently access the XMP in particular formats. It also includes a fallback packet scanner that can be used for unknown file formats.</p>
<ul>
<li>The client view of the XMPFiles API is provided through <code><a class="el" href="classTXMPFiles.html" title="API for access to the main (document-level) metadata in a file. ">TXMPFiles</a></code>.</li>
</ul>
<p>The <code>TXMP*</code> classes are C++ template classes. The templates must be instantiated for use. You can read the template header files, <a class="el" href="TXMPMeta_8hpp.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta.hpp</a>, and so on, for detailed information, but do not include them directly in your code.<br />
<br />
 There is one overall header file, <a class="el" href="XMP_8hpp.html" title="Overall header file for the XMP Toolkit. ">XMP.hpp</a>, which is the only one that C++ clients should include with the <code>include</code> directive. Read the instructions in this file for instantiating the template classes. When you have done this, the API is available through the concrete classes <code>SXMPMeta</code>, <code>SXMPUtils</code>, <code>SXMPIterator</code>, and <code>SXMPFiles</code>. <br />
<br />
 You should also read <a class="el" href="XMP__Const_8h.html" title="Common C/C++ types and constants for the XMP toolkit. ">XMP_Const.h</a> for detailed information about types and constants for namespace URIs and option flags.</p>
<h1><a class="anchor" id="second-sec"></a>
Using of the XMP Toolkit API</h1>
<p>Developers should understand the XMP Data Model before working with the XMP Toolkit. The data model is documented in the XMP Specification. The XMPCoverage sample in the SDK provides an in-depth illustration of the use of the XMP Toolkit. An XMP Programmer's Guide with tutorial examples is provided in the docs folder within the SDK. <br />
<br />
 Use of the XMP Toolkit is reasonably straightforward once you understand the XMP Data Model. An XMP property tree that conforms to the Data Model is encapsulated by a <a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a> object, and the functions of that class allow you to manipulate the namespaces, properties, and values.<br />
<br />
 To prepare XMP data for output (transferring it or embedding it in a file), it must be serialized as XML text (specifically, RDF conforming to the Serialization Model).</p>
<ul>
<li>Use <code><a class="el" href="classTXMPMeta.html#a2774a6f15ae22f0002201b58c46bfb49" title="SerializeToBuffer() serializes metadata in this XMP object into a string as RDF. ">TXMPMeta::SerializeToBuffer()</a></code> to creates the serialized XML for the data contained in the object.</li>
</ul>
<ul>
<li>Use the XMPFiles component (<code><a class="el" href="classTXMPFiles.html#afcd21cfe5d6f13c648c5541e161919cb" title="OpenFile() opens a file for metadata access. ">TXMPFiles::OpenFile()</a></code> and <code><a class="el" href="classTXMPFiles.html#ad3f7babdc07c7de0d0cd9a3362b4710a" title="PutXMP() updates the XMP metadata in this object without writing out the file. ">TXMPFiles::PutXMP()</a></code>)to write out the serialized XMP as an XMP packet embedded in a file.</li>
</ul>
<p>Similarly, you use the XMPFiles component (<code><a class="el" href="classTXMPFiles.html#a42ca0bbc5ac66a8de1710e03a7ff17b3" title="GetXMP() retrieves the XMP metadata from an open file. ">TXMPFiles::GetXMP()</a></code>) to extract an XMP packet from a file. To work with the XMP, create a <a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a> object and populate it with the data using <code><a class="el" href="classTXMPMeta.html#a7b383f5b357fff040cdbde82f4f43f26" title="ParseFromBuffer() parses RDF from a series of input buffers into this XMP object. ...">TXMPMeta::ParseFromBuffer()</a></code>. <br />
<br />
 You can use the XMPCore component to generate new XMP data.</p>
<ul>
<li>You can create your own private namespaces, but must register them before use, using <code><a class="el" href="classTXMPMeta.html#ac0368ddbaa4d689cd5b1aff1c88bb0e1" title="RegisterNamespace() registers a namespace URI with a suggested prefix. ">TXMPMeta::RegisterNamespace()</a></code>.</li>
</ul>
<ul>
<li>Property accessor functions of various kinds allow you to retrieve and set existing property values, and to create new properties.</li>
</ul>
<ul>
<li>You can get and set property values as strings, or as binary types. <a class="el" href="classTXMPUtils.html" title="API for access to the XMP Toolkit utility services. ">TXMPUtils</a> provides functions for converting between types.</li>
</ul>
<ul>
<li>Use <code><a class="el" href="classTXMPMeta.html#aeefe49bbf669770d769f4fe0ea566bd0" title="GetLocalizedText() retrieves information about a selected item in an alt-text array. ">TXMPMeta::GetLocalizedText()</a></code> and <code><a class="el" href="classTXMPMeta.html#af9531b949a462f5663b1f3fd99464c19" title="SetLocalizedText() modifies the value of a selected item in an alt-text array. ">TXMPMeta::SetLocalizedText()</a></code> when dealing with language alternative (alt-text) arrays.</li>
</ul>
<ul>
<li>Use the path composition functions provided by <a class="el" href="classTXMPUtils.html" title="API for access to the XMP Toolkit utility services. ">TXMPUtils</a> to construct complex paths with nested structs or arrays. It is recommended that you not depend on specific namespace prefixes; rather than hard-coding the prefixes for struct fields, use functions like <code><a class="el" href="classTXMPUtils.html#a706eb85b8401b8682a01348f7e25ee3d" title="ComposeStructFieldPath() composes the path expression for a field in a struct. ">TXMPUtils::ComposeStructFieldPath()</a></code> and <code><a class="el" href="classTXMPMeta.html#a0e44c30e7527064909e5f7035d53c4f5" title="SetStructField() creates or sets the value of a field within a nested structure. ">TXMPMeta::SetStructField()</a></code>.</li>
</ul>
<ul>
<li>Create a <a class="el" href="classTXMPIterator.html" title="API for access to the XMP Toolkit iteration services. ">TXMPIterator</a> object to operate on all or a subset of the properties in the metadata tree contained in a <a class="el" href="classTXMPMeta.html" title="API for access to the XMP Toolkit core services. ">TXMPMeta</a> object.</li>
</ul>
<h1><a class="anchor" id="third-sec"></a>
Overview of XMP Toolkit Internal Architecture.</h1>
<p>The XMP Toolkit is implemented in three layers, which isolate the return of string values, synchronization for multi-threaded use, and exception propagation. While the SDK as provided from Adobe builds a static library, this layering can easily be adapted to build a DLL.</p>
<ul>
<li>The top layer is the implementation of the client template classes. This layer is for copying string results and releasing the threading lock if necessary.</li>
</ul>
<ul>
<li>The middle layer consists of the three classes <code>WXMPMeta</code>, <code>WXMPIterator</code>, and <code>WXMPUtils</code>. They provide wrappers between the top client layer and the actual implementation. The middle layer is responsible for acquiring the threading lock, basic parameter checking, catching propagated exceptions, and releasing the threading lock when appropriate.</li>
</ul>
<ul>
<li>The inner layer is the actual implementation, contained in the three classes <code>XMPMeta</code>, <code>XMPIterator</code>, and <code>XMPUtils</code>.</li>
</ul>
<h2><a class="anchor" id="callchain"></a>
Implementation Call Chain</h2>
<p>The implementation of <code>GetProperty</code> provides a good illustration of the toolkit layering. The declaration below for <code><a class="el" href="classTXMPMeta.html#a06a3241c7fa5df87f61dff02fca23a0c" title="GetProperty() reports whether a property exists, and retrieves its value. ">TXMPMeta::GetProperty</a></code> is simplified by hardwiring <code>std::string</code>. The <code>XMP_StringPtr</code> type is simply <code>const char *</code>.</p>
<div class="fragment"><div class="line"><span class="keywordtype">bool</span> <a class="code" href="classTXMPMeta.html#a06a3241c7fa5df87f61dff02fca23a0c">TXMPMeta::GetProperty</a> ( <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a>    schemaNS,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a>    propName,</div><div class="line">                             std::string *    propValue,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#aeb865118433be92d88e5f49ed11487c8">XMP_OptionBits</a> * options )<span class="keyword"> const</span></div><div class="line"><span class="keyword"></span>{</div><div class="line">   <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a> resultPtr = 0;</div><div class="line">   <a class="code" href="XMP__Const_8h.html#a9f7dcc184f901c713274edfdac5bcc9a">XMP_StringLen</a> resultLen = 0;</div><div class="line"></div><div class="line">   <span class="keywordtype">bool</span> found = this-&gt;xmpObj.GetProperty ( schemaNS, propName,</div><div class="line">                                           &amp;resultPtr, &amp;resultLen, options );</div><div class="line"></div><div class="line">   <span class="keywordflow">if</span> ( found ) {</div><div class="line">       <span class="keywordflow">if</span> ( propValue != 0 ) propValue-&gt;assign ( resultPtr, resultLen );</div><div class="line">       this-&gt;xmpObj.UnlockObject ( <a class="code" href="XMP__Const_8h.html#aff1df9f3cf050f8b8d3a574db3c3326b">kXMP_NoOptions</a> );</div><div class="line">   }</div><div class="line">   <span class="keywordflow">return</span> found;</div><div class="line"></div><div class="line">}</div></div><!-- fragment --><p>The template object contains a data member pointer to the underlying <code>WXMPMeta</code> object. This is used to dispatch the call to the middle layer. The actual implementation of the XMP toolkit returns string values as a pointer and length, the pointer references private internal storage of the toolkit. The client code copies the string value to the client's string object. This minimizes the amount of string copying, and should the XMP toolkit be built as a DLL ensures that any memory allocation for the client's value is done on the client side. The call to <code>WXMPMeta::UnlockObject</code> is explained below.</p>
<div class="fragment"><div class="line"><span class="keywordtype">bool</span> WXMPMeta::GetProperty ( <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a>    schemaNS,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a>    propName,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#ad439e3ceeb4590d310f6125aa12c6df6">XMP_StringPtr</a> *  propValue,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#a9f7dcc184f901c713274edfdac5bcc9a">XMP_StringLen</a> *  valueSize,</div><div class="line">                             <a class="code" href="XMP__Const_8h.html#aeb865118433be92d88e5f49ed11487c8">XMP_OptionBits</a> * options )<span class="keyword"> const</span></div><div class="line"><span class="keyword"></span>{</div><div class="line">    <a class="code" href="XMP__Const_8h.html#a0cf68b6f47d136ed571a441a9e0d2248">XMP_Bool</a> found;</div><div class="line">    XMP_ENTER_WRAPPER ( <span class="stringliteral">&quot;WXMPMeta::GetProperty&quot;</span> )</div><div class="line"></div><div class="line">    if ( (schemaNS == 0) || (*schemaNS == 0) ) {</div><div class="line">        XMP_Throw ( <span class="stringliteral">&quot;Empty schema namespace URI&quot;</span>, <a class="code" href="XMP__Const_8h.html#adb49720dc49f7d4e4cf9adbf2948e409a2bc66eec6ce830979089d5c336f75539">kXMPErr_BadSchema</a> );</div><div class="line">    }</div><div class="line">    <span class="keywordflow">if</span> ( (propName == 0) || (*propName == 0) ) {</div><div class="line">        XMP_Throw ( <span class="stringliteral">&quot;Empty property name&quot;</span>, <a class="code" href="XMP__Const_8h.html#adb49720dc49f7d4e4cf9adbf2948e409a3f1efec0aa5452f43c55c05aba616ef7">kXMPErr_BadXPath</a> );</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> ( propValue == 0 ) propValue = &amp;voidStringPtr;</div><div class="line">    <span class="keywordflow">if</span> ( valueSize == 0 ) valueSize = &amp;voidStringLen;</div><div class="line">    <span class="keywordflow">if</span> ( options == 0 ) options = &amp;voidOptionBits;</div><div class="line"></div><div class="line">    <span class="keyword">const</span> XMPMeta &amp; meta = WtoXMPMeta_Ref ( *<span class="keyword">this</span> );</div><div class="line">    found = meta.GetProperty ( schemaNS, propName, propValue, valueSize, options );</div><div class="line"></div><div class="line">    XMP_EXIT_WRAPPER_KEEP_LOCK ( found )</div><div class="line">    return found;</div><div class="line">}</div></div><!-- fragment --><p>The entry and exit macros in the <code>WXMPMeta</code> layer acquire the threading lock on entry and usually release it on exit. The lock is kept on exit whenever a string value is returned. Since a pointer to internal data is returned, the threading lock can't be released until after the template code in the client copies the string. The entry and exit macros also prevent uncontrolled exception propagation from the lower layer back to the client. This is not critical for use of the XMP Toolkit as a static library. But it is generally not safe to propagate C++ exceptions across DLL boundaries. </p>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
  </ul>
</div>
</body>
</html>
